﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Sita.Data.Repositories;
using Sita.Entities;

namespace Sita.MainModule.Services
{
    public class ReplacementBrandService
    {
        ReplacementBrandRepository ReplacementBrandRepository;

        public ReplacementBrandService()
        {
            ReplacementBrandRepository = new ReplacementBrandRepository();
        }

        public IList<ReplacementBrand> GetAll(){
            return ReplacementBrandRepository.GetAll().ToList();
        }

        public IList<ReplacementBrand> GetAllByBusinessUnitID(int buID)
        {
            return ReplacementBrandRepository.GetAllByBusinessUnitID(buID);
        }

        public IList<ReplacementBrand> GetPaginatedReplacementBrandsByBussinesUnitID(int businessUnitID, int pageIndex, int pageSize, string sortColumn, bool ascending, out int totalRows)
        {
            return ReplacementBrandRepository.GetPaginatedByBusinessUnitID(businessUnitID, pageIndex, pageSize, sortColumn, ascending, out totalRows);
        }

        public int AddReplacementBrand(ReplacementBrand replacementBrand)
        {
            ReplacementBrandRepository.Add(replacementBrand);

            ReplacementBrandRepository.StoreContext.Commit();

            return replacementBrand.BrandID;
        }

        public ReplacementBrand GetReplacementBrandByID(int replacementBrandID)
        {
            return ReplacementBrandRepository.GetByID(replacementBrandID);
        }

        public bool ModifyReplacementBrand(ReplacementBrand replacementBrand)
        {
            ReplacementBrandRepository.Modify(replacementBrand);

            ReplacementBrandRepository.StoreContext.Commit();

            return true;
        }

        public bool DeleteReplacementBrand(ReplacementBrand replacementBrand)
        {
            ReplacementBrandRepository.Delete(replacementBrand);

            ReplacementBrandRepository.StoreContext.Commit();

            return true;
        }
        
        public ReplacementBrand GetReplacementBrandByIDWithReplacements(int replacementBrandID)
        {
            return ReplacementBrandRepository.GetByIDWithReplacements(replacementBrandID);
        }
        
    }
}
